package appcenter

import (
	"fmt"
	"git.oschina.net/YPTArch/appcenter/rpc/pd"
	"golang.org/x/net/context"
	"git.oschina.net/YPTArch/usercenter/remoteserver/rpcremote"
	"git.oschina.net/YPTArch/usercenter/remoteserver/models"
)

func RemoteGetApp(appId string ) (*models.Application){
	if appId=="" {
		return nil
	}
	appRequest:=&pb.ApplicationRequest{AppId: appId}
	r,err:= rpcremote.GetApplicationClient().GetApplication(context.Background(),appRequest)
	if r==nil|| err != nil {
		fmt.Println( err.Error())
		return nil
	}
	app:=new(models.Application)
	app.AppId=r.AppId
	app.AppSecret=r.AppSecret
	app.AppCallbackUrl=r.AppCallbackUrl
	app.AppName=r.AppName
	app.AppDesc=r.AppDesc
	app.IsDel=r.IsDel
	return app
}
